<template>
	<view class="home">
		<!-- 顶部导航 -->

		<!-- 		<view class="" @click="tapTO">
			跳转
		</view> -->
		<!-- banner -->
		<banner :bannerData="bannerData"></banner>
		<navbar :city="city"></navbar>
		<!-- navtab切换 -->
		<navtab :myCarValuation="myCarValuation" :token="token" :userInfo="userInfo" :loanStatus='loanStatus'></navtab>
		<!-- 透明车况 -->
		<transparent></transparent>
		<!-- 无忧服务 -->
		<!-- <easy-service></easy-service> -->
		<!-- 指数榜 -->
		<!-- <index-ranking></index-ranking> -->
		<!-- 资讯 -->
		<!-- <consulting :zxList="zxList"></consulting> -->
		<!-- 多选择切换列表 -->
		<!-- <tab-list :cityId="cityId"></tab-list> -->

		<view>
			<view class="aaa">
				<view class="delTit">
					<view class="titles">
						<view class="titVie" @click="ADDpaixu">
							{{paixu}}
							<image src="../../static/sanjiao.png" mode="" :class="pinpaiType?'act':''"></image>
						</view>
						<view class="titVie" @click="ADDpinpai">
							品牌
							<image src="../../static/sanjiao.png" mode=""></image>
						</view>
						<view class="titVie" @click="ADDjiage">
							价格
							<image src="../../static/sanjiao.png" mode="" :class="jiageType?'act':''"></image>
						</view>
						<view class="titVie" @click="ADDshaixuan">
							筛选
							<image src="../../static/sanjiao.png" mode=""></image>
						</view>
					</view>
					<view class="botTitle" v-if="pinpaiType">
						<view v-for="(item,index) in sortList" :key='index' @click="paixuItem(item,index)" style="display: flex;justify-content: space-between;">
							{{item.label}}
							<u-icon name="checkbox-mark" v-if="index==pinpaiTypeIndex"></u-icon>
						</view>
					</view>
					<view class="botTitle" v-if="jiageType">
						<view v-for="(item,index) in priceList" :key='index' @click="jiageItem(item.value)" style="display: flex;justify-content: space-between;">
							{{item.label}}
							<u-icon name="checkbox-mark" v-if="index==jiageTypeIndex"></u-icon>
						</view>
					</view>
				</view>

				<!-- <u-sticky :offset-top="offsetTop" h5-nav-height="50">
					<view class="sortBox _flex align-items_center _justify_between" style="background: #fff;">
						<u-dropdown ref="uDropdown" @open="open" active-color="#0e2a55" duration='0'
							menu-icon='arrow-down-fill' menu-icon-size='13'>
							<u-dropdown-item v-model="searchData.orderString" :title="form.typeSort" :options="sortList"
								@change="changeOrderString"   height='260'></u-dropdown-item>
							<u-dropdown-item title="品牌"></u-dropdown-item>
							<u-dropdown-item v-model="searchData.sellingPrice" :title="form.priceSort"
								:options="priceList" @change="changeSellingPrice"     height='260'></u-dropdown-item>
							<u-dropdown-item title="筛选"></u-dropdown-item>
						</u-dropdown>
					</view>
				</u-sticky> -->


				<view class="dropdown-item" v-if="carSelected.length>0">
					<view class="select_item" v-for="(item,index) in carSelected" :key="index" v-if="item.label"
						@click="closeSelected(index,item.id)">
						{{item.label}}
						<u-icon size="20" name="close"></u-icon>
					</view>
				</view>
				<view class="page" v-if="dataList.length > 0">
					<view class="" v-for="(item,index) in dataList" :key="index">
						<view class="tab-list-li">
							<navigator :url="`/pages/carInfo/carInfo?item=${encodeURIComponent(JSON.stringify(item))}`"
								hover-class="none">
								<tab-item :item="item"></tab-item>
							</navigator>
						</view>
					</view>
					<view class="" style="padding: 30rpx 0;">
						<u-loadmore :status="status" :load-text="loadText" />
					</view>

				</view>
				<null :iconSize="160" :textSize="28" v-else></null>
			</view>
		</view>

	</view>
</template>

<script>
	import API1 from "@/api/index.js"
	import app from "../../App.vue"
	import API from "@/api/buycar.js"
	export default {
		name: "index",
		data() {
			return {
				//是否显示品牌
				pinpaiType:false,
				pinpaiTypeIndex:0,
				//是否默认排序
				paixu:'默认排序',
				
				
				//是否显示品牌
				jiageType:false,
				jiageTypeIndex:0,
				
				
				bannerData: [],
				// treeArr:[],
				zxList: [],
				cityId: "",
				city: "",
				myCarValuation: {},
				token: '',
				userInfo: '',
				loanStatus: false,


				//底部
				hotBrandList: [],
				newCarList: [],
				indexList: [],
				checkJson: null,
				searchData: { //筛选的数据
					sellingPriceUp: "", //售价 前区间
					sellingPriceDown: "", //售价 后区间
					orderString: "", //排序字段 由下面二手车排序接口获得
					cityId: '',
					page: 1,
					limit: 10,
					mileageUp: "", //行驶里程 前区间
					mileageDown: "",
					cheLingUp: "",
					cheLingDown: "",
					seatsNumUp: "", //座位数 前区间
					seatsNumDown: "", //座位数 后区间
					numberOfTransfersUp: "", //过户次数 前区间
					numberOfTransfersDown: "", //过户次数 后区间
					rechargeMileageUp: "", //续航里程KW 前区间
					rechargeMileageDown: "", // 续航里程KW 后区间
					vehicleStructure: "", //车辆结构
					batteryType: "",
					sellingPrice: "",
					modelId: "", //车型id
					seriesId: "",
					brandId: "",
					seriesName: "",
					brandName: ""
				},

				count: 0,
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
				list: 1,
				page: 1,
				limit: 10,
				seriesId: '',
				carSelected: [

				],
				pickerValueDefault: [0, 0],
				treeData: [],
				sortList: [],
				sotrType: "",

				form: {
					typeSort: "默认排序",
					priceSort: "价格"
				},
				// cityShow: false,
				tabList: [{
						name: '二手车'
					},
					{
						name: '新车'
					}
					// , 
					// {
					// 	name: "商用车"
					// },
				],
				active: 0, //tab栏
				newTabList: [{
						name: "特价新车",
					},
					{
						name: "浏览历史",
					},
				],
				current: 0,
				locationName: "",

				modelList: [],
				dataList: [], //二手车数据列表
				newLogoList: [],
				scrollTop: 0,
				isIndexShow: false,
				typeySortShow: false,
				priceList: [{
						value: '1',
						label: '不限',
						sellingPriceUp: "", //售价 前区间
						sellingPriceDown: "", //售价 后区间
					},
					{
						value: '2',
						label: '3万以下',
						sellingPriceUp: 0,
						sellingPriceDown: 3
					},
					{
						value: '3',
						label: '3-5万',
						sellingPriceUp: 3,
						sellingPriceDown: 5
					},
					{
						value: '4',
						label: '5-10万',
						sellingPriceUp: 5,
						sellingPriceDown: 10
					},
					{
						value: '5',
						label: '10-15万',
						sellingPriceUp: 10,
						sellingPriceDown: 15
					},
					{
						value: '6',
						label: '15-20万',
						sellingPriceUp: 15,
						sellingPriceDown: 20
					},
					{
						value: '7',
						label: '20-30万',
						sellingPriceUp: 20,
						sellingPriceDown: 30
					},
					{
						value: '8',
						label: '30-40万',
						sellingPriceUp: 30,
						sellingPriceDown: 40
					},
					{
						value: '9',
						label: '40万以上',
						sellingPriceUp: 40,
						sellingPriceDown: ""
					},
				]
			}
		},

		onLoad(options) {
			this.getCitry()
			this.getBanner()
			this.getNews()
			this.getLoanStatus()
			var that = this
			if (options.platformEstimatedPriceDown) {
				that.searchData.sellingPriceUp = options.platformEstimatedPriceUp;
				that.searchData.sellingPriceDown = options.platformEstimatedPriceDown;
			}
			if (options.seriesId) {
				that.seriesId = options.seriesId;
				that.searchData.seriesId = options.modelName;
				that.searchData.seriesName = options.seriesName;
				that.searchData.seriesId = options.seriesId;
			}
			if (options.current) {
				that.current = options.current;

			}
		},
		onPageScroll(e) {
			if (e.scrollTop >= 262) {
				this.isIndexShow = true
			} else {
				this.isIndexShow = false
			}
			this.scrollTop = e.scrollTop;
		},
		onShow() {


			this.token = uni.getStorageSync('token')
			this.userInfo = uni.getStorageSync('userInfo')
			// getApp().globalData.carTypeName = ""
			this.checkLogin();
			// console.log( getApp().globalData.cityName);
			this.city = getApp().globalData.cityName
			this.cityId = getApp().globalData.cityId
			// app.globalData.cityName = ""
			// app.globalData.cityId = ""
			// uni.navigateTo({
			//     url: '/pagesB/refund/refund'
			// });


			let that = this
			that.searchData.cityId = getApp().globalData.cityId
			that.treeData = getApp().globalData.treeData

			// console.log(getApp().globalData);

			const json = getApp().globalData.carType
			if (json) { //将app中选中的车辆信息带回来

				that.searchData.seriesName = json.seriesName ? json.seriesName : "";
				that.searchData.brandName = json.brandName ? json.brandName : "";
				that.searchData.seriesId = json.seriesId ? json.seriesId : "";
				that.searchData.brandId = json.brandId ? json.brandId : "";
				app.globalData.carType = "" //清空app中的值
			}

			uni.$on('checkJson', function(data) {
				// console.log('携带参数为：', data);
				that.checkJson = {
					...data
				}
				for (let key in data) {
					if (data[key] == null) {
						data[key] = ""
					}
				}
				// that.searchData.brandId = data.brandId ?data.brandId : "";
				that.searchData.vehicleStructure = data.vehicleStructure ? data.vehicleStructure.value : '';
				that.searchData.vehicleStructureData = data.vehicleStructure ? data.vehicleStructure : '';
				that.searchData.batteryType = data.dianchi ? data.dianchi.value : '';
				that.searchData.batteryTypeData = data.dianchi ? data.dianchi : '';
				that.searchData.numberOfTransfersUp = data.guohu ? data.guohu.numberOfTransfersUp : ""; //过户次数 前区间
				that.searchData.numberOfTransfersDown = data.guohu ? data.guohu.numberOfTransfersDown : "";
				that.searchData.mileageDown = data.maxLichen;
				that.searchData.mileageUp = data.minLichen;
				that.searchData.cheLingUp = data.minYear;
				that.searchData.cheLingDown = data.maxYear;
				that.searchData.seatsNumUp = data.zuowei ? data.zuowei.seatsNumUp : ""; //过户次数 前区间
				that.searchData.seatsNumDown = data.zuowei ? data.zuowei.seatsNumDown : "";
				// that.searchData.modelId = data.modelId;
				// that.searchData.seriesId = data.seriesId;

				that.searchData.rechargeMileageUp = data.xuhang ? data.xuhang.rechargeMileageUp : "";
				that.searchData.rechargeMileageDown = data.xuhang ? data.xuhang.rechargeMileageDown : "";
				that.searchData.sellingPriceDown = data.maxPrice;
				that.searchData.sellingPriceUp = data.minPrice;
				// that.searchData.modelName = data.modelName;

				that.searchData.guohu = data.guohu;
				that.searchData.xuhang = data.xuhang;
				that.searchData.zuowei = data.zuowei;

			})

			that.getOrderList(); //二手选车排序
			that.getSelectedData(); //自定义 获取选中的数据
			that.getCarList();


		},
		onReachBottom() {
			if (this.current == 0) {
				uni.showLoading({
					title: this.status,
				});
				this.status = 'loading';
				this.searchData.page = this.searchData.page + 1;

				API.getCarList(this.searchData).then(res => {
					this.dataList = this.dataList.concat(res.data)
					// console.log(this.dataList);

					this.count = res.count
				})
				if (this.searchData.page * this.searchData.limit >= this.count) {
					this.status = 'nomore';
				} else {
					this.status = 'loadmore';
				}
			}

		},

		methods: {
			//品牌
			ADDpinpai(){
				console.log(123)
				uni.navigateTo({
					url: "/pagesA/selectCar/selectCarBuyCar"
				})
			},
			//筛选
			ADDshaixuan(){
				//价格选中区间
				if (this.searchData.sellingPriceUp && this.searchData.sellingPriceDown) {
					this.searchData.priceValues = [this.searchData.sellingPriceUp, this.searchData.sellingPriceDown]
				} else if (this.searchData.sellingPriceUp && !this.searchData.sellingPriceDown) {
					this.searchData.priceValues = [this.searchData.sellingPriceUp, 50]
				} else if (!this.searchData.sellingPriceUp && this.searchData.sellingPriceDown) {
					this.searchData.priceValues = [0, this.searchData.sellingPriceDown]
				} else {
					this.searchData.priceValues = [0, 50]
				}
				
				
				//车龄区间
				if (this.searchData.cheLingUp && this.searchData.cheLingDown) {
					this.searchData.cheLingValues = [this.searchData.cheLingUp, this.searchData.cheLingDown]
				} else if (this.searchData.cheLingUp && !this.searchData.cheLingDown) {
					this.searchData.cheLingValues = [this.searchData.cheLingUp, 10]
				} else if (!this.searchData.cheLingUp && this.searchData.cheLingDown) {
					this.searchData.cheLingValues = [0, this.searchData.cheLingDown]
				} else {
					this.searchData.cheLingValues = [0, 10]
				}
				
				
				//里程区间
				if (this.searchData.mileageUp && this.searchData.mileageDown) {
					this.searchData.mileageValues = [this.searchData.mileageUp, this.searchData.mileageDown]
				} else if (this.searchData.mileageUp && !this.searchData.mileageDown) {
					this.searchData.mileageValues = [this.searchData.mileageUp, 14]
				} else if (!this.searchData.mileageUp && this.searchData.mileageDown) {
					this.searchData.mileageValues = [0, this.searchData.mileageDown]
				} else {
					this.searchData.mileageValues = [0, 14]
				}
				
				
				// console.log("跳转时候的数据");
				// console.log(this.searchData);
				uni.navigateTo({
					url: `/pagesA/buyCar/filtrate?data=${encodeURIComponent(JSON.stringify(this.searchData))}`
				})
			},
			//排序
			ADDpaixu(){
				this.pinpaiType = !this.pinpaiType;
			},
			//价格排序
			ADDjiage(){
				this.jiageType = !this.jiageType;
			},
			//排序底部
			paixuItem(item,index){
				console.log(item)
				this.pinpaiTypeIndex = index;
				this.paixu = item.label;
				this.pinpaiType = !this.pinpaiType;
				this.searchData.orderString = item.value;
				this.getCarList();
			},
			// 价格
			jiageItem(e){
				var priceObj = this.priceList.find((val, index) => {
					return (val.value == e);
				});
				// this.form.priceSort = priceObj.label;
				this.jiageType = !this.jiageType;
				this.searchData.sellingPriceUp = priceObj.sellingPriceUp
				this.searchData.sellingPriceDown = priceObj.sellingPriceDown
				console.log(this.searchData);
				if (e == 1) {
					this.carSelected[2].label = "";
				} else {
					this.carSelected[2].label = priceObj.label;
				}
				this.getCarList();
			},
			//底部开始

			getNewCarList() {
				API.getNewCarList().then(res => {
					this.newCarList = res.data
					this.indexList = this.newCarList.map(val => {
						return val.letter;
					})
					// console.log("543543")
					// console.log(this.newCarList)
					// console.log(this.indexList)
				})

			},
			secrollTap(data) {
				uni.pageScrollTo({
					selector: '#' + data
				})
			},
			queryCity() {
				uni.navigateTo({
					url: '/pagesB/city/city'
				})
			},
			getSelectedData() {
				var ghcs = null;
				if (this.searchData.numberOfTransfersDown && this.searchData.numberOfTransfersUp) {
					ghcs = "过户" + this.searchData.numberOfTransfersDown + "次"
				} else if (this.searchData.numberOfTransfersUp && !this.searchData.numberOfTransfersDown) {
					ghcs = "过户4次以上"
				} else {
					ghcs = ""
				}
				var price = null
				if (!this.searchData.sellingPriceDown && this.searchData.sellingPriceUp != 0) {
					price = this.searchData.sellingPriceUp + "万以上"
					this.form.priceSort = "价格"
				} else if (!this.searchData.sellingPriceDown && this.searchData.sellingPriceUp == 0) {
					price = ""
				} else if (this.searchData.sellingPriceDown && !this.searchData.sellingPriceUp) {
					price = this.searchData.sellingPriceDown + "万以内"
				} else {
					price = this.searchData.sellingPriceUp + '万-' + this.searchData.sellingPriceDown + '万'
					this.form.priceSort = "价格"
				}
				var cheling = null
				if (!this.searchData.cheLingDown && this.searchData.cheLingUp == 0) {
					cheling = ""
				} else if (!this.searchData.cheLingDown && this.searchData.cheLingUp != 0) {
					cheling = this.searchData.cheLingUp + "年以上"
				} else {
					cheling = this.searchData.cheLingUp + '年-' + this.searchData.cheLingDown + '年'
				}

				var licheng = null
				if (!this.searchData.mileageDown && this.searchData.mileageUp == 0) {
					licheng = ""
				} else if (!this.searchData.mileageDown && this.searchData.mileageUp != 0) {
					licheng = this.searchData.mileageUp + "万公里以上"
				} else {
					licheng = this.searchData.mileageUp + '万公里-' + this.searchData.mileageDown + '万公里'
				}

				var rechargeMileag = null
				if (this.searchData.rechargeMileageDown && !this.searchData.rechargeMileageUp) {
					rechargeMileag = this.searchData.rechargeMileageDown + "km以内"
				} else if (this.searchData.rechargeMileageDown && this.searchData.rechargeMileageUp) {
					rechargeMileag = this.searchData.rechargeMileageUp + 'km-' + this.searchData.rechargeMileageDown + 'km'
				} else if (!this.searchData.rechargeMileageDown && this.searchData.rechargeMileageUp) {
					rechargeMileag = this.searchData.rechargeMileageUp + 'km以上'
				} else {
					rechargeMileag = ""
				}

				var seatsNum = null
				if (this.searchData.seatsNumUp && this.searchData.seatsNumDown) {
					seatsNum = this.searchData.seatsNumUp + "座"
				} else if (this.searchData.seatsNumUp == 7 && !this.searchData.seatsNumDown) {
					seatsNum = this.searchData.seatsNumUp + '座以上'
				} else {
					seatsNum = ""
				}


				this.carSelected = [{
						selectedName: '品牌:',
						label: this.searchData.brandName,
						id: "brandId"
					},
					{
						selectedName: '车系:',
						label: this.searchData.seriesName,
						id: "seriesId"
					},
					{
						selectedName: '车价:',
						label: price,
						id: "sellingPrice"
					},
					{
						selectedName: '车身结构:',
						label: this.searchData.vehicleStructure,
						id: "vehicleStructure"
					},
					{
						selectedName: '座位数:',
						label: seatsNum,
						id: "seatsNum"

					},
					{
						selectedName: '车龄:',
						label: cheling,
						id: 'cheLing'
					},
					{
						selectedName: '里程:',
						label: licheng,
						id: "mileage"

					},

					{
						selectedName: '过户次数',
						label: ghcs,
						id: "numberOfTransfer"
					},
					{
						selectedName: '续航里程:',
						label: rechargeMileag,
						id: "rechargeMileage"
					},
					{
						selectedName: '电池类型:',
						label: this.searchData.batteryType,
						id: "batteryType"
					}

				]
				// console.log("xuanze");
				// console.log(this.carSelected);
			},
			open(index) {
				// if (index == 1) {
				// 	this.$refs.uDropdown.close();
				// 	uni.navigateTo({
				// 		url: "/pagesA/selectCar/selectCarBuyCar"
				// 	})
				// } else if (index == 3) {
					
				// }
			},
			// 获取车辆列表
			getCarList() {
				// console.log(this.searchData);
				this.searchData.page = 1;
				console.log(this.searchData)
				API.getCarList(this.searchData).then(res => {

					// console.log(res)
					this.dataList = res.data
					this.count = res.count
					for (let i = 0; i < res.data.length; i++) {
						// console.log(res.data[i].carRegistrationTime.substring(0,10))
						this.dataList[i].carRegistrationTime = res.data[i].carRegistrationTime.substring(0, 10)

					}
				})
				if (this.searchData.page * this.searchData.limit >= this.count) {
					this.status = 'nomore';
				} else {
					this.status = 'loadmore';
				}
			},


			closeSelected(index, id) {
				// console.log(index);
				if (id == 'brandId') {
					this.searchData.seriesId = "";
					this.searchData.seriesName = "";
					this.searchData.brandId = "";

					this.searchData.brandName = "";
					if (this.checkJson) {
						this.checkJson.brandId = "";
						this.checkJson.seriesId = "";
						this.checkJson.modelName = "";
					}
					this.carSelected[1].label = ""
				}
				if (id == 'seriesId') {
					this.searchData.seriesId = "";
					this.searchData.seriesName = "";
					this.carSelected[1].label = ""
				}
				if (id == 'sellingPrice') {
					this.searchData.sellingPriceUp = "";
					this.searchData.sellingPriceDown = "";
				}
				if (id == 'vehicleStructure') {
					this.searchData.vehicleStructure = "";
					this.searchData.vehicleStructureData = ""
				}
				if (id == 'seatsNum') {
					this.searchData.seatsNumUp = "";
					this.searchData.seatsNumDown = "";
					this.searchData.zuowei = "";

				}
				if (id == 'cheLing') {
					this.searchData.cheLingUp = "";
					this.searchData.cheLingDown = "";
				}
				if (id == 'mileage') {
					this.searchData.mileageUp = "";
					this.searchData.mileageDown = "";
				}
				if (id == 'numberOfTransfer') {
					this.searchData.numberOfTransfersUp = "";
					this.searchData.numberOfTransfersDown = "";

					this.searchData.guohu = "";


				}
				if (id == 'rechargeMileage') {
					this.searchData.rechargeMileageUp = "";
					this.searchData.rechargeMileageDown = "";
					this.searchData.xuhang = "";
				}
				if (id == 'batteryType') {
					this.searchData.batteryType = "";
					this.searchData.batteryTypeData = "";
				}
				this.carSelected[index].label = ""
				this.getCarList();
			},
			getOrderList() { //默认排序下拉数据
				API.getOrderList().then(res => {
					this.sortList = res.data;
					console.log(res.data)
				})
			},
			changeOrderString(e) {
				console.log(e);
				var orderStringObj = this.sortList.find((val, index) => {
					return (val.value == e);
				});
				this.form.typeSort = orderStringObj.label;
				this.searchData.orderString = e;
				this.getCarList();
			},
			changeSellingPrice(e) {
				console.log(e);
				var priceObj = this.priceList.find((val, index) => {
					return (val.value == e);
				});
				// this.form.priceSort = priceObj.label;
				console.log(priceObj);
				this.searchData.sellingPriceUp = priceObj.sellingPriceUp
				this.searchData.sellingPriceDown = priceObj.sellingPriceDown
				console.log(this.searchData);
				if (e == 1) {
					this.carSelected[2].label = "";
				} else {
					this.carSelected[2].label = priceObj.label;
				}
				this.getCarList();
			},

			// onConfirm(e) { //改变city的时候
			// 	this.city = e.secondPick.name;
			// 	this.cityId = e.secondPick.code;
			// 	this.searchData.cityId = e.secondPick.code;
			// 	getApp().globalData.cityId = this.cityId 
			// 	getApp().globalData.cityName =this.city
			// 	this.getCarList();
			// },


			// 价格排序
			priceConfirm(e) {
				console.log(e)
				this.form.priceSort = e[0].label
				var index = this.priceList.findIndex((v) => {
					return v.label == e[0].label;
				});
				console.log(index);
				this.searchData.sellingPriceUp = this.priceList[index].sellingPriceUp
				this.searchData.sellingPriceDown = this.priceList[index].sellingPriceDown
				console.log(this.searchData);
				this.getCarList();

			},
			// 排行榜
			rankingList(e) {
				console.log(e)
				uni.navigateTo({
					url: "../rankingList/rankingList?active=" + e
				})
			},
			// 新车条件筛选-多选
			imgChecked(e) {
				let check = e.checked
				console.log(check)
				e.checked = !check
			},
			usedCarDetail(e) {
				uni.navigateTo({
					url: "./usedCarDetail"
				})
			},
			newCarDetail(e) {
				uni.navigateTo({
					url: "./newCarDetail"
				})
			},
			tabChange(index) {
				this.current = index;
				if (this.current == 0) {
					this.getCarList()
				} else if (this.current == 1) {
					this.getNewCarList()
					this.getHotBrand();
				}
			},
			search() {
				uni.navigateTo({
					url: "../index/search"
				})
			},
			pinpai() {
				uni.navigateTo({
					url: "../selectCar/selectCarBuyCar"
				})
			},

			tabNewChange(idx) {
				this.active = idx
			},



			getHotBrand() { //新车热门品牌
				API.getHotBrand().then(res => {
					this.hotBrandList = res.data
					console.log(this.hotBrandList)
				})
			},


			// 底部结束
			tapTO() {
				uni.navigateTo({
					url: '/pagesA/newCarDep/newCarDep'
				})
			},
			checkLogin() {
				// 先判断在调用
				if (this.token && this.userInfo) {
					// this.getIndexValuation();
				}
			},

			// 获取轮播图
			getBanner() {
				const data = {
					position: 1
				}
				API1.getBanner(data).then(res => {
					this.bannerData = res.data
				})
			},
			// 获取城市
			getCitry() {
				API1.getCitry({}).then(res => {
					this.treeArr = res.data
					// this.cityId = res.data[0].children[0].code
					getApp().globalData.treeData = res.data
					// getApp().globalData.cityId = res.data[0].children[0].code
					// getApp().globalData.cityName = res.data[0].children[0].name
				})
			},
			// 获取资讯
			getNews() {
				const data = {
					page: 1,
					limit: 20,
				}
				API1.getNews(data).then(res => {
					this.zxList = res.data;
				})
			},
			// 获取首页估值情况
			// getIndexValuation() {
			// 	API1.getIndexValuation({}).then(res => {
			// 		// console.log(res);
			// 		this.myCarValuation = res.data
			// 	})
			// },
			// 获取贷款状态
			getLoanStatus() {
				API1.getLoanStatus().then(res => {
					// console.log(res.data.status)
					this.loanStatus = res.data.status
					// console.log("this.loanStatus" + this.loanStatus)
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.act{
		transform: rotate(180deg);
	}
	.delTit {
		position: relative;
	}

	.titles {
		padding: 32rpx;
		display: flex;
		justify-content: space-between;

		image {
			width: 13rpx;
			height: 8rpx;
			margin-left: 10rpx;
			margin-top: 17rpx;
		}

		.titVie {
			display: flex;
		}
	}

	.botTitle {
		position: absolute;
		min-height: 400rpx;
		background: #fff;
		z-index: 111;
		padding: 0 32rpx;
		width: 100%;
		view {
			width: 100%;
			padding: 26rpx 0;
			font-size: 28rpx;
			line-height: 54rpx;
			border-top: 1rpx solid #f5f5f5;
		}
	}

	page {
		height: 100%;
		display: flex;
	}

	.home {
		display: flex;
		flex-direction: column;
		flex: 1;
		background-color: #eee;
		padding-bottom: 40rpx;
		box-sizing: border-box;
	}

	.sanjiao {
		width: 10rpx;
		height: 8rpx;
		margin-left: 10rpx;
		margin-top: 45rpx;
	}

	#topsss {
		height: 100rpx;
		line-height: 100rpx;
		width: 100%;
		border-bottom: 1rpx solid #d8d8d8;
	}

	.hearder {
		text-align: center;
		margin-top: 0;
		color: #888;
		font-size: 30rpx;
	}

	.sortBox {
		/* 		background: #FBF8F9; */
		color: #888;
		height: 100rpx;
		padding: 0 24rpx;
		box-sizing: border-box;
	}

	.head_inputBox {
		padding: 0 24rpx;
		margin: 30rpx;
		border: 1px solid #002B56;
		border-radius: 17rpx;
	}

	.news-wrap {
		margin-left: 20rpx;
		line-height: 45rpx;
		color: #333333;
	}

	.newsTxt {
		width: 340rpx;
		display: inline-block;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.tips {
		width: 30rpx;
		height: 30rpx;
	}

	.newsTip {
		background: #F4E5C3;
		display: inline-block;
		padding: 0 8rpx;
		font-size: 22rpx;
		margin-right: 8rpx;
		border-radius: 10rpx;
	}

	.dataList {
		margin-top: 10px;
		border-bottom: 1px solid #eee;
		padding-bottom: 10rpx;
		margin-top: 20rpx;
	}


	.buyList .buyItem {
		width: 20%;
		color: #666666;
		text-align: center;
		padding: 10rpx;
		box-sizing: border-box;
	}

	.i_tem {
		display: inline-block;
		padding: 10rpx 0;
		background: #F7F8FC;
		width: 18%;
		text-align: center;
		margin-bottom: 20rpx;
	}

	.tabBox {
		color: #002B56;
		align-items: flex-end;
	}

	.tabName {
		font-size: 30rpx;
		padding-bottom: 20rpx;
	}

	.tabBox .active {
		font-size: 36rpx;
		font-weight: bold;
		border-bottom: 2px solid #002B56;

	}

	.checkActive {
		background: #4472C4 !important;
		color: #fff !important;
		;
	}

	.modelBox {
		width: 100%;
		line-height: 40rpx;
		display: flex;
	}

	.modelBox .modelContext {
		width: 52%;
		margin-left: 3%;
	}

	.list-cell {
		display: flex;
		align-items: center;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: $u-content-color;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
	}

	.dropdown-item {
		display: flex;
		flex-wrap: wrap;
		padding: 10rpx 24rpx 0 24rpx;
		box-sizing: border-box;
		/* justify-content: space-between; */

	}

	.select_item {
		border: 1px solid #eee;
		line-height: 60rpx;
		font-size: 26rpx;
		color: #666;
		padding: 0 20rpx;
		height: 60rpx;
		margin-right: 15rpx;
		margin-bottom: 15rpx;
	}

	.select_item u-icon {
		margin-left: 10rpx;
	}

	.tab-list-li {
		border-bottom: 1px solid #efefef;
		padding: 20rpx 0;
	}

	.page {
		margin-bottom: 30rpx;
		margin: 0 12px
	}

	.aaa {
		background: #fff;
	}
</style>
